package com.xzy.controller;

import com.xzy.model.req.UserCreateReq;
import com.xzy.model.resp.UserCreateResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 前后端参数映射
 *
 * @author xzy.xiao
 * @date 2023/9/11  19:04
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @PostMapping("/create")
    public UserCreateResp create(@RequestBody UserCreateReq req) {
        UserCreateResp resp = new UserCreateResp()
                .setUserId("1001")
                .setUserName(req.getUserName())
                .setUserAge(req.getUserAge())
                .setUserPhone(req.getUserPhone());

        log.info("接收的数据：{}", req);
        log.info("返回的数据：{}", resp);

        return resp;
    }
}
